package com.etoak.common.core.vo;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVO<T> {
    public static final int DEFAULT_SUCCESS_CODE = 200;
    public static final int DEFAULT_ERROR_CODE = 500;

    public static final String DEFAULT_SUCCESS_MESSAGE = "Success";
    public static final String DEFAULT_ERROR_MESSAGE = "Error";

    private Integer code;
    private T data;
    private String msg;

    public static <T> ResultVO<T> success() {
        return new ResultVO<>(DEFAULT_SUCCESS_CODE, null, DEFAULT_SUCCESS_MESSAGE);
    }

    public static <T> ResultVO<T> success(T data) {
        return new ResultVO<>(DEFAULT_SUCCESS_CODE, data, DEFAULT_SUCCESS_MESSAGE);
    }

    public static <T> ResultVO<T> error() {
        return new ResultVO<>(DEFAULT_ERROR_CODE, null, DEFAULT_ERROR_MESSAGE);
    }

    public static <T> ResultVO<T> error(String error) {
        return new ResultVO<>(DEFAULT_ERROR_CODE, null, error);
    }
}
